﻿#include "apprunninginfo.h"

AppRunningInfo::AppRunningInfo()
{

}

int AppRunningInfo::decodeParametersFromTlv(TLV *tlv)
{
    if (tlv->tag == AppRunningInfoTag_name)
    {
        this->name = tlv->buffer;
    }
    else if (tlv->tag == AppRunningInfoTag_startCmd)
    {
        this->startCmd = tlv->buffer;
    }
    else if (tlv->tag == AppRunningInfoTag_type)
    {
        this->type = tlv->buffer;
    }
    else if (tlv->tag == AppRunningInfoTag_runningState)
    {
        this->runningState = tlv->buffer;
    }
    else if (tlv->tag == AppRunningInfoTag_cfgInfo)
    {
        this->cfgInfo = tlv->buffer;
    }
    else
    {
        LOG_ERROR("unexpedted tlv tag:%d", tlv->tag);
    }

    return f_success;
}

int AppRunningInfo::encodeParametersIntoTlvs(list<TLV *> &tlvs)
{
    tlvs.push_back(createTlvByStringValue(AppRunningInfoTag_name, name));
    tlvs.push_back(createTlvByStringValue(AppRunningInfoTag_startCmd, startCmd));
    tlvs.push_back(createTlvByStringValue(AppRunningInfoTag_type, type));
    tlvs.push_back(createTlvByStringValue(AppRunningInfoTag_runningState, runningState));
    tlvs.push_back(createTlvByStringValue(AppRunningInfoTag_cfgInfo, cfgInfo));
    return f_success;
}
